import Foundation

public struct Test_Number {
    /// 反转整数
    public static func reverse(_ x: Int) -> Int {
        var reversed = 0
        var number = x
        let sign = x < 0 ? -1 : 1
        number = abs(number)
        
        while number != 0 {
            let digit = number % 10
            reversed = reversed * 10 + digit
            number /= 10
        }
        
        return sign == 1 ? reversed : -reversed
    }
}


